package cn.edu.scau.dormitory_management_system.module.examine.service.impl;

import cn.edu.scau.dormitory_management_system.module.examine.dao.FlowNodeDao;
import cn.edu.scau.dormitory_management_system.module.examine.entity.FlowNodeEntity;
import cn.edu.scau.dormitory_management_system.module.examine.service.FlowNodeService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author ：Vizzk
 * @description：TODO
 * @date ：2021/8/5 16:56
 */
@Service("flowNodeService")
public class FlowNodeServiceImpl extends ServiceImpl<FlowNodeDao, FlowNodeEntity> implements FlowNodeService {

    @Override
    public boolean insertFlowNode(FlowNodeEntity flowNode) {
        return this.baseMapper.insert(flowNode)>0;
    }

    @Override
    public List<FlowNodeEntity> listFlowNodes() {
        return this.baseMapper.selectList(null);
    }

    @Override
    public List<FlowNodeEntity> listFlowNodesByFlowId(Integer flowId) {
        QueryWrapper<FlowNodeEntity> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("flow_id",flowId);
        queryWrapper.orderByAsc("flow_node_id");
        List<FlowNodeEntity> flowNodes = this.baseMapper.selectList(queryWrapper);
        return flowNodes;
    }


}
